﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HsTec.DigitalPlatform.DataAccess
{
    public class FileInfoRepository
    {
        DigitalPlatformEntities db = new DigitalPlatformEntities();

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="userinfo"></param>
        public void Add(FileInfo fileinfo)
        {
            db.AddToFileInfos(fileinfo);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="userinfo"></param>
        public void Delete(FileInfo fileinfo)
        {
            db.DeleteObject(fileinfo);
        }

        /// <summary>
        /// 保存
        /// </summary>
        public void Save()
        {
            db.SaveChanges();
        }

        /// <summary>
        /// 根据ID查询实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FileInfo GetFileInfoByID(int id)
        {
            return db.FileInfos.Single<FileInfo>(d => d.fileid == id);
        }

        /// <summary>
        /// 返回所有实体
        /// </summary>
        /// <returns></returns>
        public IQueryable<FileInfo> FindALLFileInfo()
        {
            return db.FileInfos;
        }
    }
}
